<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>我要成为城市运营中心合伙人</title>
    <script src="__INDEX__/js/mui.min.js"></script>
	<link href="__INDEX__/css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="__INDEX__/css/iconfont.css" />
	<link rel="stylesheet" href="__INDEX__/css/style.css" />
	<link rel="stylesheet" href="__INDEX__/css/mall.css" />	
	<script type="text/javascript" src="__INDEX__/dist/jquery.min.js" ></script>
	<script type="text/javascript" src="__INDEX__/js/menudown.js" ></script>
</head>
<body>
	<div class="mui-content" style="background-color: #fff;">
	    {include file="public/member" /}
	     <div class="glj_bt"><span class="mui-icon iconfont icon-dingdan4"></span><em style="padding-left: 20px;">我要成为合伙人</em></div>
	     <div class="glj_bt1">
	     	{if $sh&&$sh['status']==3}
			<p >审核失败-退回原因:<em style="color: red;">{$sh['reason']}</em></p>
		{/if}
	     <p ><div class="glj_bt1" style="text-align: center;">合伙人申请</div></p>
	     <p style="margin-top: 10px;"><em style="padding-right: 20px;">申请 人 姓 名</em><input id="name" value="{if $sh}{$sh['name']}{/if}"  style="font-size:12px;width:200px;height: 30px;line-height: 30px;border-radius: 15px;"  type="text" placeholder="请输入姓名"/></p>
	  	 <p style="margin-top: 10px;"><em style="padding-right: 20px;">申请人手机号</em><input id="mobile" value="{if $sh}{$sh['mobile']}{/if}" style="font-size:12px;width:190px;height: 30px;line-height: 30px;border-radius: 15px;"  type="text" placeholder="请输入手机号"/></p>
	  	 <p style="margin-top: 10px;"><em style="padding-right: 20px;">申请人微信号</em><input id="wxh" value="{if $sh}{$sh['wxh']}{/if}" style="font-size:12px;width:190px;height: 30px;line-height: 30px;border-radius: 15px;"  type="text" placeholder="请输入微信号"/></p>
	  	 <p style="margin-top: 20px;">
	  	 	<em style="padding-right: 20px;float: left;">上传合伙人付款凭证</em>
			<div class="renz_img" id="yyzz_pic" style="float: left;" >
				<input type="hidden" name="pz" id="pz" value="{if $sh}{$sh['pz']}{/if}" lay-verify="required" id="thumb_1">
				<input type="file" style="width: 80px;height: 80px;" id="upload_1" class="upload1" value="选择图片文件" multiple="">
				<span><img onclick="$('input[id=upload_1]').click();" style="width: 80px;height: 80px;" class="img_1" id="img_1" src="{if $sh}{$sh['pz']}{else}__INDEX__/images/up.jpg {/if}"></span>
			</div>
	  	 </p>
		</div>
		<div  class="glj_bt1" >
		{if !$sh||($sh&&$sh['status']==3)}
		<button class="tixian_btn" onclick="submit_tx(this)">确认申请</button>
		{elseif $sh&&$sh['status']==1}
			<button class="tixian_btn" onclick="alert('您已经提交申请,请等待审核')">审核中</button>
		{/if}
		</div>
	</div>
			{include file="public/bottom" /}
</body>
</html>
	{include file="public/footer" /}
<script src="__PUBLIC__/static/js/mui.min.js"></script>
<script>
	$(function () {
				$('#upload_1').on('change', function() {
					readFile1(this,"pz",1);
				});
		});
	function submit_tx(obj){
		$(obj).attr("disabled","disabled");
		var name=$("#name").val();
		var mobile=$("#mobile").val();
		var wxh=$("#wxh").val();
		var pz=$("#pz").val();
		if(name==""||mobile==""||wxh==""){
			layer.msg("请填写完相关资料!");
			return false;
		}
		if(pz==""){
			layer.msg("请上传付款凭证");
			return false;
		}
			$.ajax({
				type: 'post',
				url: 'sq_city',
				data: {
					name:name,
					mobile:mobile,
					wxh:wxh,
					pz:pz
				},
				success: function(data) {
						layer.msg(data.msg, {
						  icon: 1,
						  time: 1500 //2秒关闭（如果不配置，默认是3秒）
						}, function(){
							//location.href = "{:url('index')}";
						});
				}
			})
	
					
	}
	/**
 * 上传图片
 * name 存储图片form元素id
 * length 上传张数
 */
function readFile1(input, name, length) {
	var img_list = $(input).parent().find('span').find("img");
	if(input.files && input.files[0]) {
			var reader = new FileReader();
	   		var AllImgExt="image/jpg|image/jpeg|image/png|image/bmp";  
            var extName = input.files[0].type.toLowerCase();//（把路径中的所有字母全部转换为小写）          
            if(AllImgExt.indexOf(extName+"|")==-1)          
            {  
                ErrMsg="该文件类型不允许上传。请上传 "+AllImgExt+" 类型的文件，当前文件类型为"+extName;  
                alert(ErrMsg);  
                return false;  
            }  
		var fd = new FormData();
		  var sendData;
		for(var i = 0; i < input.files.length; i++) {
			var reader = new FileReader();
			reader.readAsDataURL(input.files[i]);
				reader.onload = function (event) {
				    var img = new Image();
				    img.onload = function () {
				    	var canvas = document.createElement("canvas"); 
				    	canvas.width=500;
				    	canvas.height=500*img.height/img.width;
							var ctx = canvas.getContext('2d'); 
							ctx.clearRect(0, 0, canvas.width, canvas.height); 
                            ctx.drawImage(img, 0, 0, 500,500*img.height/img.width);
                            var newImageData=canvas.toDataURL('image/jpeg',0.8);
					        sendData = newImageData.replace("data:"+'image/jpeg'+";base64,",'');
				        	$.post("upload1",{value:sendData},function(data){  
	                            if(data.code == '200'){  
	                                $("#"+name).val(data.url);
									img_list.attr("src",data.url);
	                            }else{  
	                                layer.msg(data.msg);
	                            }  
                    		}); 
					}
				    img.src = reader.result;
           		}
			
		}
		
	} else {
		alert("抱歉，你的浏览器不支持 FileReader");
	}
}

</script>
